﻿/**
* 
* analysis XML to different array
* for init to use
* 
*/

class analysisXML
{
	public var t1:Number = new Number();
	public var st_arr:Array = new Array();
	private var elxml:XML;
	
	function analysisXML()
	{
		t1 = 150;
		trace('t1: ' + t1);	
		elxml = new XML();
		elxml.ignoreWhite = true;
		elxml.onLoad = function(success:Boolean){
			if(success){
				trace("loading success!");
				st_arr = this.firstChild.childNodes;
			}else{
				trace("loading error")
			}
		}
		
		elxml.load("selection.xml");
		parseXML();

	}
	
	//===================================================================================
	// parseXML
	//-----------------------------------------------------------------------------------
	
	public function parseXML(){
		// trace topNode and it's  name
		trace('topNode and it  name: ');
		trace(elxml.firstChild.nodeName+":"+elxml.firstChild.attributes.pic_path);
		//st_arr
		//st_arr = elxml.firstChild.childNodes;
		for (var i = 0; i<st_arr.length; i++) {
			trace("=======evert selection==============");
			trace(st_arr[i].nodeName+" : "+ st_arr[i].attributes.id);
			//var child_arr:Array = st_arr[i].firstChild.childNodes;
			for (var j = 0; j<st_arr[i].childNodes.length; j++){
				trace(st_arr[i].childNodes[j].nodeName+" : "+ st_arr[i].childNodes[j].firstChild.nodeValue);
				// print text
				if(j==1){
					for(var k = 0; k<st_arr[i].childNodes[1].childNodes.length; k++){
						trace(st_arr[i].childNodes[1].childNodes[k].nodeName+" : "+st_arr[i].childNodes[1].childNodes[k].firstChild.nodeValue);
					}
				}
				//print thumbnail
				if(j==2){
					for(var k = 0; k<st_arr[i].childNodes[2].childNodes.length; k++){
						trace(st_arr[i].childNodes[2].childNodes[k].nodeName+" : "+st_arr[i].childNodes[2].childNodes[k].firstChild.nodeValue);
					}
				}
			}
			
		}
		//load_BGBoard(1);
		//load_thumbnail(1);
	}

	
	
}